package com.kaifamiao.demo.d0826;

import java.util.List;
import java.util.stream.Stream;

public class Demo05 {

    public static void main(String[] args) {
        // 现在有两个ArrayList集合，分别存储6名男演员名称和6名女演员名称
        List<String> men = List.of("吴彦祖", "蔡徐坤", "吴磊", "胡歌", "倪大红", "刘学义");
        List<String> women = List.of("迪丽热巴", "古力娜扎", "张天爱", "杨幂", "李冰冰", "杨紫");

        // 男演员只要名字为3个字的前三人
        Stream<String> stream = men.stream().filter(str -> str.length() == 3)
                .limit(3);
        // 女演员只要姓杨的，并且不要第一个
        Stream<String> stream1 = women.stream().filter(str -> str.startsWith("杨"))
                .skip(1);
        // 把过滤后的男演员姓名和女演员姓名合并到一起
        Stream<String> concat = Stream.concat(stream, stream1);

        concat.forEach(str -> System.out.println(new Actor(str)));

    }
}


class Actor {
    private String name;

    public Actor(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "Actor{" +
                "name='" + name + '\'' +
                '}';
    }
}
